package com.mdsoft.service.impl;

import com.mdsoft.dao.AdminDao;
import com.mdsoft.po.Admin;
import com.mdsoft.service.AdminService;

public class AdminServiceImpl implements AdminService {

	private AdminDao adminDao;
	
	@Override
	public void changePassword(int id, String oldPassword, String newPassword) {
		Admin admin = adminDao.get(id);
		if (admin != null && admin.getPassword().equals(oldPassword)) {
			admin.setPassword(newPassword);
			adminDao.update(admin);
		}
		
	}

	@Override
	public Admin login(String username, String password) {
		return adminDao.login(username, password);
	}

	public AdminDao getAdminDao() {
		return adminDao;
	}

	public void setAdminDao(AdminDao adminDao) {
		this.adminDao = adminDao;
	}

}
